// Sound Group
// (c) jimon game studio

#include "CSoundGroup_Squall.h"

#ifdef JE_SOUND_SQUALL

namespace je
{
	namespace sound
	{
		//! Constructor
		CSoundGroup_Squall::CSoundGroup_Squall()
		{
		}

		//! Desturctor
		CSoundGroup_Squall::~CSoundGroup_Squall()
		{
			RemoveSound(NULL);
		}

		//! Add Sound
		void CSoundGroup_Squall::AddSound(ISound * Sound)
		{
			JEASSERT(Sound)

			SoundList.push_back(Sound);
			Sound->Grab();
		}

		//! Remove Sound
		void CSoundGroup_Squall::RemoveSound(ISound * Sound)
		{
			if(Sound)
			{
				for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
					if((*Iter) == Sound)
					{
						Sound->Drop();
						SoundList.erase(Iter);
						return;
					}
			}
			else
			{
				for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
					(*Iter)->Drop();
				SoundList.clear();
			}
		}

		//! Play
		void CSoundGroup_Squall::Play()
		{
			for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
				(*Iter)->Play();
		}

		//! Stop
		void CSoundGroup_Squall::Stop()
		{
			for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
				(*Iter)->Stop();
		}

		//! Pause
		void CSoundGroup_Squall::Pause(u1 Enable)
		{
			for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
				(*Iter)->Pause(Enable);
		}

		//! Set Volume
		void CSoundGroup_Squall::SetVolume(s32 Volume)
		{
			for(SoundListType::Iterator Iter = SoundList.begin(); Iter != SoundList.end();Iter++)
				(*Iter)->SetVolume(Volume);
		}
	}
}

#endif
